home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 60.zip / BS1 part 60 / Imagemaster d5.adf / piarc.lzh.parta / hist.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-22  |  4KB  |  138 lines

  1. /*
  2.  * histr.rexx
  3.  *
  4.  *  Written by: Pete Patterson
  5.  * Last Update: January 15, 1992
  6.  *         For: Black Belt Systems image processing series IM, IM F/c, and IP.
  7.  * ---------------------------------------------------------------------------
  8.  *    Revision: 1.0
  9.  */
  10. call pragma('stack',20000);
  11.  
  12. /*
  13.  * open rexxsupport.library -- needed for some functions
  14.  */
  15. if ~show('L',"rexxsupport.library") then do
  16.   if addlib('rexxsupport.library',0,-30,0) then do
  17.       /* everything's ok */
  18.     end;
  19.   else do
  20.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  21.     say 'Cannot operate targar.rexx without this library - sorry!';
  22.     exit 10;
  23.     end;
  24.   end;
  25.  
  26. /*
  27.  * This will automatically direct the script to the proper
  28.  * software, if it is running.
  29.  */
  30. prtnme = 'IP_Port'; /* assume Image Professional */
  31. if show('P','IP_Port') = 0 then do
  32.   if show('P','IM_Port') = 0 then do
  33.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  34.     say "This script requires IP, IM or IM F/c to run!";
  35.     exit(20);
  36.     end;
  37.   else do
  38.     prtnme = 'IM_Port'; /* That's the thing about assumptions... */
  39.     end;                 /* We make em, user's break em.          */
  40.   end;
  41.  
  42. options;
  43. address;
  44.  
  45.   prevpath = 'ram:'; /* put user in ram to start with... */
  46.  
  47.   if show('C',histpath) = 1 then do
  48.     prevpath = getclip(histpath);
  49.     end;
  50.  
  51.   address(prtnme);
  52.   options results;
  53.   'current';
  54.   bufdata = result; /* get name of buffer, if there is one */
  55.   parse var bufdata bname ',' bnum ',' bx ',' by ',' btot ',' bmem ',' bparname ',' bparnum;
  56.   if bname ~= '<none>' then do
  57.     bufname = bname;
  58.     end;
  59.   'filerequest "'||prevpath||'","'||bufname||'","","Save HIST"';
  60.   histfile = result;
  61.   options;
  62.  
  63.   if histfile = 'FR_CANCELLED' then do
  64.     address(prtnme);
  65.     'imtofront';
  66.     exit 0;
  67.     end;
  68.  
  69.   histfile = expandfilename(histfile);
  70.   thispath = gimmepath(histfile);
  71.   call setclip(histpath,thispath);
  72.  
  73.   address(prtnme);
  74.   options results;
  75.   'jackin';
  76.   jackadr = result;
  77.   options;
  78.  
  79.   address command 'cmpi:hist '||jackadr||' "'||histfile||'" "'||bufname||'"';
  80.  
  81.   address(prtnme);
  82.   'imtofront';
  83.   address;
  84.  
  85.   exit 0;
  86.  
  87. /*
  88.  * gimmepath
  89.  *
  90.  * This takes the provided argument and sucks the path out of it, then
  91.  * returns that path to the caller, sans file name.
  92.  */
  93. gimmepath:
  94.   arg fullnamegx;
  95.     tempgx = reverse(fullnamegx);
  96.     lengx = length(fullnamegx);   /* get length of string */
  97.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  98.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  99.     seploc = 0; /* assumes current dir, no path supplied */
  100.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  101.       seploc = (lengx - slashdex)+1;
  102.       end;
  103.     else do
  104.       if colondex ~= 0 then do /* we assume we are on a device */
  105.         seploc = (lengx - colondex)+1;
  106.         end;
  107.       end;
  108.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  109.   gxpath = left(fullnamegx,seploc);
  110.   return(gxpath);
  111.  
  112. /*
  113.  * Since this script can't be expected to know where the CD of the user
  114.  * is when this cmd is invoked, we have to check the path the user
  115.  * provides - if it's not specified right from a root, then we have
  116.  * to make it a complete specification from the root.
  117.  */
  118. expandfilename:
  119.   parse arg jfile;
  120.   if index(jfile,':') = 0 then do
  121.     curdir = pragma(D);
  122.     if right(curdir,1) ~= ':' then do
  123.       if right(curdir,1) ~= '/' then do
  124.         if curdir ~= '' then do
  125.           curdir = curdir || '/';
  126.           end;
  127.         end;
  128.       end;
  129.     jfile = curdir||jfile;
  130.     end;
  131.   return(jfile);
  132.  
  133. rvalue:
  134.   wordnum = c2d(readch(fhandle,1)) * 256;
  135.   wordnum = wordnum + c2d(readch(fhandle,1));
  136.   return wordnum;
  137.  
  138.